package cn.com.infostrategy.bs.sysapp.userrole;

import java.util.Vector;

import cn.com.infostrategy.bs.common.CommDMO;
import cn.com.infostrategy.bs.common.ServerEnvironment;
import cn.com.infostrategy.bs.mdata.styletemplet.t01.IBSIntercept_01;
import cn.com.infostrategy.to.mdata.BillVO;


public class RoleManagerBSIntercept implements IBSIntercept_01 {

	private CommDMO dmo = null;

	public void dealAfterCommit(String _dsName, BillVO[] _insertobjs, BillVO[] _deleteobjs, BillVO[] _updateobjs) throws Exception {
		if (_deleteobjs != null && _deleteobjs.length > 0) {
			Vector v_sql = new Vector(); //
			for (int i = 0; i < _deleteobjs.length; i++) {
				String str_roleid = _deleteobjs[i].getPkValue(); //
				String str_1 = "delete from pub_user_role where roleid='" + str_roleid + "'"; //
				String str_2 = "delete from pub_role_menu where roleid='" + str_roleid + "'"; //
				v_sql.add(str_1);
				v_sql.add(str_2);
			}
			getDMO().executeBatchByDS(_dsName, v_sql); //
		}
	}

	public void dealBeforeCommit(String _dsName, BillVO[] _insertobjs, BillVO[] _deleteobjs, BillVO[] _updateobjs) throws Exception {

	}

	private CommDMO getDMO() {
		if (dmo == null) {
			dmo = ServerEnvironment.getCommDMO();
		}
		return dmo;
	}
}
